'''
Created on Jan 25, 2011

@author: mikeg
'''

from multiprocessing import Process
import os
import time

def sleeper(name, seconds):
    print 'starting child process with id: ', os.getpid()
    print 'parent process: ', os.getppid()
    print 'sleeping for %s ' % seconds
    time.sleep(seconds)
    print "waek up, %s!" % name
    
def moar():
    print time.clock()

if __name__ == '__main__':
    print "in parent process (id %s)" % os.getpid()
    p = Process(target=sleeper, args=('bob', 5))
    q = Process(target=sleeper, args=('jane', 3))
    a = Process(target=sleeper, args=('rofl', 2))
    c = Process(target=moar)
    c.start()
    p.start()
    q.start()
    a.start()
    print "in parent process after child process start"
    print "parent process about to join child process"
    p.join()
    q.join()
    a.join()
    c.join()
    moar()
    print "in parent process after child process join"
    print "parent process exiting with id ", os.getpid()
    print "the parent's parent process: ", os.getppid()